<?php
class Default_View_Filter_CheckCustomer 
{
	private $_error;
	private $_messagesError;
	public function __construct($data)
	{
		$validator = new Zend_Validate_StringLength(1,32);
		if (!$validator->isValid($data['customer_fname']))	
		{
			$this->_messagesError[]="First Name: ".current($validator->getMessages())." or not blank";
		}	
		
//		$validator = new Zend_Validate_StringLength(1,32);
//		if (!$validator->isValid($data['customer_lname']))	
//		{
//			$this->_messagesError[]="Last Name: ".current($validator->getMessages())." or not blank";
//		}
		
		$validator = new Zend_Validate_EmailAddress();
		if (!$validator->isValid($data['customer_email'])&&!empty($data['customer_email']))	
		{
			$this->_messagesError[]="Email Address: ".current($validator->getMessages())." or not blank";
		}
		$data['customer_birthday'] = str_ireplace("/","-",$data['customer_birthday']);
		$format = Zend_Date::DAY.'-'.Zend_Date::MONTH.'-'.Zend_Date::YEAR;
		if (!Zend_Date::isDate($data['customer_birthday'],$format)&&!empty($data['customer_birthday']))
		{
			$this->_messagesError[]="Customer Birthday: date must be format like dd-mm-yyyy";
		}		
		$this->_error = count($this->_messagesError)==0?true:false;	
	}
	public function isValid()
	{
		return $this->_error;
	}
	public function getMessages()
	{
		return $this->_messagesError;
	}
}

